<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Base URL
 *
 * Returns the "base_url" item from your config file
 *
 * @access    public
 * @return    string
 */
function base_url($module=''){
    $CI =& get_instance();
    $ret = $CI->config->slash_item('base_url');
    if($module != ''){
        $arr = Modules::search_path($module);
        $module_dir = $arr[3].'/'.$arr[0];
        $ret .= 'application/modules/'.$module_dir.'/assets/';
    }
    return $ret;
}

function set_flash_message($msg){
    $CI =& get_instance();
    $CI->session->set_flashdata('flash_message', $msg);
    return true;
}

function get_flash_message(){
    $CI =& get_instance();
    return $CI->session->flashdata('flash_message');
}

function uri_segment($idx){
    $CI =& get_instance();
    return $CI->uri->segment($idx);
}

function hostname(){
    $s = '';
    if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']='on')
        $s = 's';
    return 'http'.$s.'://'.rtrim($_SERVER['HTTP_HOST'], '/');
}